package com.example.movie.data.movie.factory

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.example.movie.data.cinema.model.CinemaDataSource
import com.example.movie.data.cinema.model.CinemaRepository
import com.example.movie.data.cinema.model.vm.CinemaViewModel

/**
 * ViewModel provider factory to instantiate LoginViewModel.
 * Required given LoginViewModel has a non-empty constructor
 */
class CinemaViewModelFactory : ViewModelProvider.Factory {

    @Suppress("UNCHECKED_CAST")
    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        if (modelClass.isAssignableFrom(CinemaViewModel::class.java)) {
            return CinemaViewModel(
                repository = CinemaRepository(
                    dataSource = CinemaDataSource()
                )
            ) as T
        }
        throw IllegalArgumentException("Unknown ViewModel class")
    }
}